package com.copm.ifm.servers.sys.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.copm.ifm.base.api.pojo.PageDTO;
import com.copm.ifm.base.api.pojo.PageVO;
import com.copm.ifm.base.basic.constant.DbConstants;
import com.copm.ifm.base.basic.util.AuthUtil;
import com.copm.ifm.base.service.mp.page.PageProxy;
import com.copm.ifm.servers.sys.entity.SysMessageSend;
import com.copm.ifm.servers.sys.mapper.SysMessageSendMapper;
import com.copm.ifm.servers.sys.service.SysMessageSendService;
import com.copm.ifm.servers.sys.vo.SysMessageSendVO;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.Date;

/**
 * 消息发送接口 服务实现类
 *
 * @author tp
 * @since 2021-01-04
 */
@Service
public class SysMessageSendServiceImpl extends ServiceImpl<SysMessageSendMapper, SysMessageSend> implements SysMessageSendService {

    @Resource
    SysMessageSendMapper sysMessageSendMapper;

    @Override
    public PageVO<SysMessageSendVO> selectForPage(PageDTO<SysMessageSend> pageDTO) {
        return PageProxy.proxy(baseMapper::selectForPage, pageDTO);
    }

    @Override
    public SysMessageSend selectById(int id) {
        return baseMapper.selectById(id);
    }

    @Override
    public int updateDeleted(int id) {
        SysMessageSend sysMessageSend = new SysMessageSend();
        sysMessageSend.setId(id);
        sysMessageSend.setDeleted(DbConstants.DEFAULT_YES);
        return sysMessageSendMapper.updateById(sysMessageSend);
    }

    @Override
    public SysMessageSendVO selectVoById(int id) {
        return sysMessageSendMapper.selectVOById(id);
    }

    @Override
    public void updateEntityById(SysMessageSend entity) {
        entity.setUpdateBy(AuthUtil.getCurrentUserId());
        entity.setUpdateTime(new Date());
        updateById(entity);
    }
}
